//js实现深拷贝和浅拷贝

function clone(obj) {
    const newObj = obj instanceof Array ? [] : {};
    for (let key in obj) {
        newObj[key] = typeof obj[key] === 'object' ? clone(obj[key]) : obj[key];
    }
    return newObj;
}
